import request from '@/utils/requestH2'

/* 申请 */

// 获取申请列表
export function selAskListApi(params) {
  return request({
    url: '/ask/selAskList',
    method: 'GET',
    params
  })
}

// 新增申请
export function addAskApi(data) {
  return request({
    url: '/ask/addAsk',
    method: 'POST',
    data
  })
}

// 新增审核通过购货单
export function addOKBuyGoodsApi(data) {
  return request({
    url: "/ask/addOKBuyGoods",
    method: "POST",
    data
  });
}


// 根据id修改申请
export function updateAskByIdApi(data) {
  return request({
    url: `/ask/updateAskById/${data.id}`,
    method: 'PUT',
    data: {
      askGoods: data.askGoods || data.goodsList, // 商品列表数组
      askType: data.askType, // 申请类型
      askUrl: data.askUrl, // 附件URL
      directorId: data.directorId, // 负责人id
      needDepartmentId: data.needDepartmentId, // 需求部门id
      operatorId: data.operatorId, // 操作人id
      remark: data.remark // 备注
    }
  })
}

// 根据ids删除申请
export function delAskByIdApi(id) {
  return request({
    url: `/ask/delAskById/${id}`,
    method: 'DELETE'
  })
}

// 根据id处理申请
export function updateAskStatusByIdApi(data) {
  return request({
    url: `/ask/updateAskStatusById/${data.id}`, // 根据id处理申请
    method: 'PUT',
    data: {
      operatorId: data.operatorId, // 操作人id
      remark: data.remark // 备注
    }
  })
}

/* 资源管理部列表 */
export function selResourcesInspectListApi(params) {
  return request({
    url: '/business/selBusinessInspectList',
    method: 'GET',
    params
  })
}

// 资源管理部根据id审批
export function ResourcesInspectByIdApi(data) {
  return request({
    url: '/business/BusinessInspectById',
    method: 'PUT',
    data
  })
}

// 资源管理部根据id进行编辑
export function BusinessInspectUpdateByIdApi(askId, data) {
  return request({
    url: `/business/BusinessInspectUpdateById/${askId}`,
    method: 'PUT',
    data
  })
}

/* 商务管理列表 */
export function selBusinessInspectListApi(params) {
  return request({
    url: '/resources/selResourcesInspectList',
    method: 'GET',
    params
  })
}

// 商务管理部根据id审批
export function BusinessInspectByIdApi(data) {
  return request({
    url: '/resources/ResourcesInspectById',
    method: 'PUT',
    data
  })
}

// 商务管理部根据ids合并审批
export function ResourcesInspectByIdsApi(data) {
  return request({
    url: '/resources/ResourcesInspectByIds',
    method: 'PUT',
    data
  })
}

/* 分管副总审核列表 */
export function selAssistantBossInspectListApi(params) {
  return request({
    url: '/assistantBoss/selAssistantBossInspectList',
    method: 'GET',
    params
  })
}

// 分管副总根据id审批
export function assistantBossInspectByIdApi(data) {
  return request({
    url: '/assistantBoss/AssistantBossInspectById',
    method: 'PUT',
    data
  })
}

/* 总经理集合 */
export function selBossInspectListApi(params) {
  return request({
    url: '/boss/selBossInspectList',
    method: 'GET',
    params
  })
}

// 总经理根据id审批
export function bossInspectByIdApi(data) {
  return request({
    url: '/boss/BossInspectById',
    method: 'PUT',
    data
  })
}

/* 上传图片 */

// 文件上传
export function uploadFileApi(data) {
  return request({
    url: '/file/uploadFile',
    method: 'POST',
    data
  })
}
